home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 44 / Amiga Format CD44 (1999-08-26)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-10].iso / -in_the_mag- / basics / blitz / bfbblitz.lha / SDSBFBPlayer / BlitzConversion / SDSBFBPlayerGUI.ASC next >
Text File  |  1999-04-22  |  11KB  |  429 lines

  1. ;
  2. ; SDSBFBPlayer V1.00 (C) Robert Hutchinson (22/04/1999)
  3. ; Uses routines written by Robert Hutchinson & David McMinn.
  4. ; BFBPlayMaster.library and sublibs are (C) Jarkko Vatjus-Anttila
  5. ;
  6. ; This source requires:
  7. ;
  8. ;   o bfbplaymaster.library1 in your BlitzLibs:AmigaLibs/ (+ compiled deflibs)
  9. ;   o the bfbplaymaster.library in LIBS: and Replayers/ in LIBS:
  10. ;   o The SDSBFB.RES file resident in the compiler menu.
  11. ;   o The AmigaLibs.RES file resident in compiler menu.
  12. ;   o The Blitz Support Suite would be nice ;)
  13. ;
  14. ; Satanic Dreams Software 1999, Visit:
  15. ;   http://www.satanicdreams.freeserve.co.uk/
  16. ;
  17. ; NOTE!: The BFBPrevPattern{} and BFBNextPattern{} commands cause
  18. ;        overflow errors according to the debugger, but are perfectly
  19. ;        safe (honest ;)). Just switch overflow checking off when using the
  20. ;        debugger ;) (BTW - It`s only the error code ;))
  21. ;
  22.  
  23. WBStartup
  24. WbToScreen 0
  25. WBenchToFront_
  26.  
  27. XINCLUDE "Blitz2:BlitzBFBPlayer/BFB_Include.BB2"  ;Our include!
  28.  
  29. *WBScreen.Screen=Peek.l(Addr Screen (0))    ;Grab some stuff from the
  30. FontHeight = *WBScreen\Font\ta_YSize        ;screen structure.
  31. BarHeight  = *WBScreen\BarHeight
  32.  
  33. NoMod$     = "No Module loaded!"      ;Some presets.
  34. Shrunk     = 1
  35. FullSize   = 68+FontHeight
  36. ShrunkSize = 20+FontHeight
  37. InfoHeight = 149+FontHeight
  38.  
  39.   If FromCLI AND Par$(1)="?"
  40.     DefaultOutput
  41.     NPrint "SDSBFBPlayer V1.00 (C) Robert Hutchinson 1999"
  42.     NPrint "A perfect example of how to use our BFB conversion ;)"
  43.     NPrint ""
  44.     NPrint "  CLI USAGE: SDSBFBPlayer <Mod_Path$>"
  45.     NPrint ""
  46.     End
  47.   EndIf
  48.  
  49.   Statement GadToggle{Win,GTL,IDENT,OOSwitch} ;for toggling GT gadgets <--
  50.     If OOSwitch=On
  51.       GTEnable GTL,IDENT
  52.     Else
  53.       GTDisable GTL,IDENT
  54.     EndIf
  55.     Redraw   Win,IDENT
  56.   End Statement
  57.  
  58.   ; ######################################################[ Our GUI ]##
  59.  
  60.   ;-- Our Menu Lists!
  61.   ;
  62.   GTMenuTitle 0,0,"Project"
  63.     GTMenuItem 0,0,0,0,"About","?"
  64.     GTMenuItem 0,0,0,1,"About Satanic Dreams!","$"
  65.     GTMenuItem 0,0,0,2,"About the BFB Libs."
  66.     GTMenuItem 0,0,0,3
  67.     GTMenuItem 0,0,0,4,"Fold <-> UnFold","U"
  68.     GTMenuItem 0,0,0,5,"Quit","Q"
  69.  
  70.   GTMenuTitle 0,1,"PlayBack"
  71.     GTMenuItem 0,0,1,0,"Play","P"
  72.     GTMenuItem 0,0,1,1,"Stop","S"
  73.     GTMenuItem 0,0,1,2,"Continue","C"
  74.     GTMenuItem 0,0,1,3
  75.     GTMenuItem 0,0,1,4,"Forward Pattern Jump","F"
  76.     GTMenuItem 0,0,1,5,"Backward Pattern Jump","B"
  77.     GTMenuItem 0,0,1,6
  78.     GTMenuItem 0,0,1,7,"Eject","E"
  79.  
  80.   ;--- Our gadget list!
  81.   ;
  82.   GTButton 0,50,  0, 0, 27,15,">" ,$5 ;Top set
  83.   GTButton 0,51, 27, 0, 27,15,"<>",$5
  84.   GTButton 0,52, 54, 0, 27,15,"O" ,$5
  85.   GTButton 0,53, 81, 0, 27,15,"<<",$5
  86.   GTButton 0,54,108, 0, 27,15,">>",$5
  87.   GTButton 0,55,135, 0, 27,15,"^" ,$5
  88.   GTButton 0,62,162, 0, 30,15,"?" ,$5
  89.  
  90.   GTButton 0,56,  0,18, 90,15,"ModInfo",$5 ;Info bar
  91.   GTText   0,59, 90,18, 25,15,"",$1,"00"
  92.   GTText   0,60,125,18, 25,15,"",$1,"00"
  93.   GTText   0,61,150,18, 42,15,"",$1,"0%"
  94.  
  95.   GTText   0,57,  0,33,192,15,"",$1,NoMod$ ;more Infos
  96.   GTText   0,58,  0,48,192,15,"",$1,NoMod$
  97.  
  98.   Window 0,ScreenWidth/2-(200/2),ScreenHeight/2-(ShrunkSize/2),200,ShrunkSize,$1000|$2|$4|$8,"SDSBFBPlayer (V1.00)",1,0
  99.   GTSetMenu 0
  100.   If NOT AddAppWindow(0)
  101.     sel.b=RTEZRequest("Error!","ERROR: Unable to generate appwindow!","Terminate!")
  102.     End
  103.   EndIf
  104.  
  105.   AttachGTList 0,0
  106.   If FromCLI AND NumPars=1
  107.     NewFile$=Par$(1)
  108.     Gosub LoadUpFile
  109.   EndIf
  110.  
  111.   Gosub SystemCheck
  112.  
  113.   ; #[ Main Loop ]########################################[ End Our GUI ]##
  114.  
  115.   Repeat
  116.     Delay_ 1
  117.     EV.l=Event
  118.     If EV=$40           ;Check the gadgets
  119.       Select GadgetHit
  120.         Case 50
  121.           Gosub PlayMe
  122.         Case 51
  123.           succ.b=BFBContModule{}
  124.         Case 52
  125.           BFBStopModule{}
  126.         Case 53
  127.           Gosub PatPrev
  128.         Case 54
  129.           Gosub PatNext
  130.         Case 55
  131.           BFBStopModule{}
  132.           BFBFreeModule{}
  133.           Gosub NoModule
  134.           Gosub SystemCheck
  135.         Case 62
  136.           Gosub FoldUnFold
  137.         Case 56
  138.           Gosub InitAddit
  139.       End Select
  140.     EndIf
  141.  
  142.     If EV=$100           ;Check the menus
  143.       Select MenuHit
  144.         Case 0
  145.           Select ItemHit
  146.             Case 0:Gosub About
  147.             Case 1:Gosub AboutSDS
  148.             Case 2:Gosub AboutBFB
  149.  
  150.             Case 4:Gosub FoldUnFold
  151.             Case 5:EV=$200
  152.           End Select
  153.         Case 1
  154.           Select ItemHit
  155.             Case 0:Gosub PlayMe
  156.             Case 1:BFBStopModule{}
  157.             Case 2:succ.b=BFBContModule{}
  158.             Case 4:Gosub PatPrev
  159.             Case 5:Gosub PatNext
  160.             Case 7
  161.               BFBStopModule{}
  162.               BFBFreeModule{}
  163.               Gosub NoModule
  164.               Gosub SystemCheck
  165.           End Select
  166.       End Select
  167.     EndIf
  168.  
  169.     If AppEvent
  170.       NewFile$=AppFile(1)
  171.       Gosub LoadUpFile
  172.     EndIf
  173.  
  174.     Gosub ReThinkPosition
  175.  
  176.   Until EV=$200
  177.  
  178.   ; #[ Program Ends ]##################################[ End Main Loop ]##
  179.  
  180.   ; Program ends!
  181.   BFBStopModule{}
  182.   BFBFreeModule{}
  183.  
  184. End
  185.  
  186.   ; #[ Sub-Routines ]#####################################################
  187.  
  188.  
  189.   SetupDisplay
  190.     GTSetString 0,57,BFBModuleName{}
  191.     GTSetString 0,58,BFBModuleType{}
  192.  
  193.     GTSetString 0,59,Str$(BFBCurrentPosition{})
  194.     GTSetString 0,60,Str$(BFBMaxPositions{})
  195.     GTSetString 0,61,Str$(BFBPlayPercentage{})+"%"
  196.   Return
  197.  
  198.   ReThinkPosition
  199.     If BFBModLoaded{}=True
  200.       NewPos=BFBCurrentPosition{}
  201.       If CurPos<>NewPos
  202.         CurPos=NewPos
  203.         GTSetString 0,59,Str$(CurPos)
  204.         GTSetString 0,61,Str$(BFBPlayPercentage{})+"%"
  205.       EndIf
  206.     EndIf
  207.   Return
  208.  
  209.   NoModule
  210.     GTSetString 0,57,NoMod$
  211.     GTSetString 0,58,NoMod$
  212.  
  213.     GTSetString 0,59,"00"
  214.     GTSetString 0,60,"00"
  215.     GTSetString 0,61,"0%"
  216.   Return
  217.  
  218.   GeneralModErr
  219.     lock.l=RTLockWindow(0)
  220.     sel.b=RTEZRequest("Error!","ERROR: "+BFBParseError{succ},"Ok!")
  221.     RTUnlockWindow 0,lock
  222.   Return
  223.  
  224.   PatternErr
  225.     lock.l=RTLockWindow(0)
  226.     sel.b=RTEZRequest("Error!","ERROR: Module doesn`t support pattern jumping!","Ok!")
  227.     RTUnlockWindow 0,lock
  228.   Return
  229.  
  230.   FoldUnFold
  231.     Use Window 0
  232.     DetachGTList 0
  233.     If Shrunk=1
  234.       If (WindowY+FullSize)>WBHeight         ;Protect from bottom of screen
  235.         WMove WindowX,WBHeight-(FullSize)
  236.       EndIf
  237.       WSize 200,FullSize
  238.       WindowOutput 0:Use Window 0:Wline 118,48,128,33,1 ;Draw the forward slash.
  239.       Shrunk=0
  240.       AttachGTList 0,0
  241.       GTBevelBox 0,4,BarHeight+16,192,3,$0
  242.       wbarheight
  243.     Else
  244.       WSize 200,ShrunkSize
  245.       Shrunk=1
  246.       AttachGTList 0,0
  247.     EndIf
  248.  
  249.     If BFBModLoaded{}=True
  250.       Gosub SetupDisplay
  251.     Else
  252.       Gosub NoModule
  253.     EndIf
  254.  
  255.   Return
  256.  
  257.   InitAddit
  258.     If BFBModLoaded{}=True
  259.       Gosub AdditionalInfoWin
  260.     EndIf
  261.   Return
  262.  
  263.   PatNext
  264.     succ.b=BFBNextPattern{}
  265.     If succ=-1
  266.       Gosub PatternErr
  267.     EndIf
  268.   Return
  269.  
  270.   PatPrev
  271.     succ.b=BFBPrevPattern{}
  272.     If succ=-1
  273.       Gosub PatternErr
  274.     EndIf
  275.   Return
  276.  
  277.   PlayMe
  278.     succ.b=BFBPlayModule{}
  279.     If succ<>0
  280.       Gosub GeneralModErr
  281.     EndIf
  282.   Return
  283.  
  284.   About
  285.     lock.l=RTLockWindow(0)
  286.     InnerTxt$="SDSBFBPlayer V1.00"+Chr$(10)+Chr$(10)
  287.     InnerTxt$+"This program (apart from being really groovy ;)) is"+Chr$(10)
  288.     InnerTxt$+"an example of how easy it is to use the bfbplaymaster.library"+Chr$(10)
  289.     InnerTxt$+"through Blitz2 with our C->Blitz conversion and includes."+Chr$(10)
  290.     InnerTxt$+"The package has 22 commands for use with BFB."+Chr$(10)+Chr$(10)
  291.     InnerTxt$+"The BFB conversion was written by:"+Chr$(10)
  292.     InnerTxt$+"   Robert Hutchison &"+Chr$(10)
  293.     InnerTxt$+"   David McMinn"+Chr$(10)+Chr$(10)
  294.     InnerTxt$+"DATE: 22/04/1999"+Chr$(10)
  295.     InnerTxt$+"Have fun!"
  296.     sel.b=RTEZRequest("About this program",InnerTxt$,"Ok!")
  297.     RTUnlockWindow 0,lock
  298.   Return
  299.  
  300.   AboutSDS
  301.     lock.l=RTLockWindow(0)
  302.     InnerTxt$="Satanic Dreams Software"+Chr$(10)+Chr$(10)
  303.     InnerTxt$+"SDS was a designgroup, but shortly, we will be working"+Chr$(10)
  304.     InnerTxt$+"on a possible commercial game, and are dropping the "+Chr$(10)
  305.     InnerTxt$+"design group image."+Chr$(10)+Chr$(10)
  306.     InnerTxt$+" Visit our website:"+Chr$(10)
  307.     InnerTxt$+"   HTTP://www.satanicdreams.freeserve.co.uk"+Chr$(10)+Chr$(10)
  308.     InnerTxt$+" Or Email Admin:"+Chr$(10)
  309.     InnerTxt$+"   admin@satanicdreams.freeserve.co.uk"
  310.     sel.b=RTEZRequest("About Satanic Dreams Software",InnerTxt$,"Ok!")
  311.     RTUnlockWindow 0,lock
  312.   Return
  313.  
  314.   AboutBFB
  315.     lock.l=RTLockWindow(0)
  316.     InnerTxt$="About BFB"+Chr$(10)+Chr$(10)
  317.     InnerTxt$+"BFB consists of a 13 Amiga shared libraries, 1 master lib"+Chr$(10)
  318.     InnerTxt$+"and 12 sublibs. The master lib is used to control the sub"+Chr$(10)
  319.     InnerTxt$+"libraries automatically. And it is very easy to use."+Chr$(10)+Chr$(10)
  320.     InnerTxt$+"BFB is (C): Jarkko Vatjus-Anttila"+Chr$(10)+Chr$(10)
  321.     InnerTxt$+"Replayers are (C) to their respective authors."+Chr$(10)
  322.     sel.b=RTEZRequest("About BFB",InnerTxt$,"Ok!")
  323.     RTUnlockWindow 0,lock
  324.   Return
  325.  
  326.   AdditionalInfoWin
  327.     lock.l=RTLockWindow(0)
  328.     FlushEvents
  329.  
  330.     ClearList BFBSamples()
  331.     ResetList BFBSamples()
  332.     AddFirst BFBSamples()
  333.     BFBInitSamples{}
  334.     DefaultOutput
  335.     BFBMS=BFBMaxSamples{}
  336.     If BFBMS=0 OR BFBMS=1
  337.       BFBSamples()\Text="   **********************************":AddItem BFBSamples()
  338.       BFBSamples()\Text="   *** No sample texts availible! ***":AddItem BFBSamples()
  339.       BFBSamples()\Text="   **********************************"
  340.     Else
  341.       For TSP=0 To BFBMS
  342.         If TSP<10
  343.           SN$="0"+Str$(TSP)+": "
  344.         Else
  345.           SN$=Str$(TSP)+": "
  346.         EndIf
  347.         BFBSamples()\Text=SN$+BFBGetSampleName{TSP}
  348.         If TSP<>BFBMS
  349.           AddItem BFBSamples()
  350.         EndIf
  351.       Next
  352.     EndIf
  353.  
  354.     ;--- Our gadget list!
  355.     ;
  356.     GTText     1,50, 70,  0,272,15,"  Name:",$1,BFBModuleName{}
  357.     GTText     1,51, 70, 15,272,15,"Format:",$1,BFBModuleType{}
  358.     GTText     1,52, 70, 30,272,15,"Length:",$1,Str$(BFBModuleLength{})
  359.  
  360.     GTListView 1,53,  0, 45,342,86,"",$1,BFBSamples()
  361.  
  362.     GTText     1,54, 70,129,272,15," Songs:",$1,Str$(BFBMaxSongs{})
  363.  
  364.     DefaultIDCMP $40027C|$2|$4|$8|$10|$20|$40|$100|$200|$400|$8000|$10000|$40000|$80000
  365.     Window 1,ScreenWidth/2-(350/2),ScreenHeight/2-(InfoHeight/2),350,InfoHeight,$1000|$2|$4|$8,"SDSBFBPlayer Info",1,0
  366.  
  367.     AttachGTList 1,1
  368.  
  369.     Repeat
  370.       Delay_ 1
  371.       EV.l=WaitEvent
  372.       If EV=$200
  373.         If EventWindow=1
  374.           quitflag=1
  375.         EndIf
  376.       EndIf
  377.     Until quitflag=1
  378.     quitflag=0
  379.     EV=0
  380.     DetachGTList 1
  381.     Free GTList 1
  382.     CloseWindow 1
  383.     FlushEvents
  384.  
  385.     RTUnlockWindow 0,lock
  386.   Return
  387.  
  388.   SystemCheck
  389.     If BFBModLoaded{}=True
  390.       Switch=On
  391.     Else
  392.       Switch=Off
  393.     EndIf
  394.  
  395.     GTMenuState 0,1,0,Switch
  396.     GTMenuState 0,1,1,Switch
  397.     GTMenuState 0,1,2,Switch
  398.     GTMenuState 0,1,4,Switch
  399.     GTMenuState 0,1,5,Switch
  400.     GTMenuState 0,1,7,Switch
  401.     For TSP=50 To 56
  402.       GadToggle{0,0,TSP,Switch}
  403.     Next
  404.   Return
  405.  
  406.   LoadUpFile
  407.     BFBStopModule{}
  408.     BFBFreeModule{}
  409.  
  410.     succ=BFBLoadModule{NewFile$}
  411.     If succ<>0
  412.       Gosub GeneralModErr
  413.       Gosub NoModule
  414.     Else
  415.       Gosub SetupDisplay
  416.     EndIf
  417.  
  418.     succ.b=BFBPlayModule{}
  419.     If succ<>0
  420.       Gosub GeneralModErr
  421.     EndIf
  422.     Gosub SystemCheck
  423.   Return
  424.  
  425.   ; ################################################[ End Sub-Routines ]##
  426.  
  427.  
  428.  
  429.